package com.lixw.springai.controller;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * @ClassName: MCPClientCallBaiduMcpController
 * @Description:
 * @Author: xuweiLi
 * @Create: 2025/8/26 19:37
 **/
@RestController
public class MCPClientCallBaiduMcpController {
    @Resource
    private ChatClient chatClient;

    @Resource
    private ChatModel chatModel;

    @GetMapping("/mcp/chat")
    public Flux<String> chat(@RequestParam("msg") String msg) {
        return chatClient.prompt(msg).stream().content();
    }

    @RequestMapping("/mcp/chat2")
    public Flux<String> chat2(@RequestParam("msg") String msg) {
        return chatModel.stream(msg);
    }
}